package logic

import (
	"context"
	"errors"
	"go.uber.org/zap"
	"order_srv/internal/dao"
	"order_srv/internal/svc"
	"order_srv/order"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type InvoiceLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewInvoiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InvoiceLogic {
	return &InvoiceLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 全部发票列表
func (l *InvoiceLogic) Invoice(in *order.InvoiceRequest) (*order.InvoiceResponse, error) {
	//业务逻辑
	list, err := dao.Invoice(in)
	if err != nil {
		pkg.Error("发票查询失败", zap.Error(err))
		return nil, errors.New("发票查询失败")
	}
	pkg.Info("发票查询成功", zap.Any("invoiceList", list))
	return &order.InvoiceResponse{
		List: list,
	}, nil
}
